-
Notifications
You must be signed in to change notification settings - Fork 0
/
ukmmonstring.php
111 lines (101 loc) · 2.84 KB
/
ukmmonstring.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<?php
/*
Plugin Name: UKM Mønstring
Plugin URI: http://www.ukm-norge.no
Description: UKM Norge admin
Author: UKM Norge / M Mandal
Version: 2.0
Author URI: http://www.ukm-norge.no
*/
use UKMNorge\Wordpress\Modul;
require_once('UKM/Autoloader.php');
class UKMmonstring extends Modul
{
public static $action = 'monstring';
public static $path_plugin = null;
/**
* Register hooks
*/
public static function hook()
{
// Kun mønstringssider skal ha arrangement-meny
if (is_numeric(get_option('pl_id'))) {
add_action(
'admin_menu',
['UKMmonstring', 'meny'],
1000
);
}
add_action(
'wp_ajax_UKMmonstring',
['UKMmonstring', 'ajax']
);
}
/**
* Rendre meny
*
*/
public static function meny()
{
try {
$arrangement = static::getArrangement();
$page = add_submenu_page(
'index.php',
'Videresending',
'Videresending',
'editor',
'UKMarrangement_videresending',
['UKMMonstring', 'renderAdminVideresending'],
40
);
add_action(
'admin_print_styles-'.$page,
['UKMmonstring', 'scripts_and_styles']
);
} catch( Exception $e ) {
// Do nothing: skal ikke ha den uansett da
}
add_action(
'admin_print_styles-index.php',
['UKMmonstring', 'scripts_and_styles']
);
}
public static function renderAdminVideresending() {
static::setAction('videresending');
return static::renderAdmin();
}
/**
* Scripts and styles for non-network admin
*
*/
public static function scripts_and_styles()
{
wp_enqueue_media();
wp_enqueue_script('TwigJS');
wp_enqueue_script(
'UKMMonstring_script_monstring',
UKMmonstring::getPluginUrl() . 'js/monstring.js'
);
wp_enqueue_script(
'UKMMonstring_script_kontaktpersoner',
UKMmonstring::getPluginUrl() . 'js/kontaktpersoner.js'
);
wp_enqueue_script(
'UKMMonstring_script_videresending',
UKMmonstring::getPluginUrl() . 'js/videresending.js'
);
wp_enqueue_script(
'UKMMonstring_script_skjema',
UKMmonstring::getPluginUrl() . 'js/skjema.js'
);
wp_enqueue_style(
'UKMMonstring_style',
UKMmonstring::getPluginUrl() . 'monstring.style.css'
);
wp_enqueue_script('jQuery_autogrow');
wp_enqueue_script('WPbootstrap3_js');
wp_enqueue_style('WPbootstrap3_css');
}
}
UKMmonstring::init(__DIR__);
UKMmonstring::hook();