-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathukmwp_admin-tweaks.php
215 lines (163 loc) · 7.91 KB
/
ukmwp_admin-tweaks.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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
<?php
/*
Plugin Name: UKM WP Admin Tweaks
Plugin URI: http://www.ukm-norge.no
Description: Tweaker WP-admin litt her og der for å få det til å se bra ut. (tidligere del av UKMNorge plugin)
Author: UKM Norge / M Mandal
Version: 1.0
Author URI: http://www.ukm-norge.no
*/
require_once('UKMconfig.inc.php');
require_once('tweak.logon.php');
#require_once('tweak.mail.php');
require_once('tweak.login.php');
require_once('tweak.video_on_top.php');
// Bytt ut WP-logoen med UKM-logoen på innloggingsskjermen
add_filter('login_head', 'UKMwpat_login');
// Endrer URL til UKM-logoen
add_filter( 'login_headerurl', 'UKMwpat_login_logo_url' );
add_filter( 'login_headertext', 'UKMwpat_login_logo_url_title' );
// Bytt lost-password-lenken mot mailto:[email protected]
add_action('lostpassword_url', 'UKMWpat_lostpassword' );
add_filter( 'gettext', 'UKMWpat_change_lost_your_password' );
add_action('wp_login', 'UKMwpat_login_redirect', 10, 2);
add_filter('login_message', 'UKMwpat_login_message');
add_filter('login_redirect', 'UKMwpat_login_rfid', 10, 3);
add_action('show_user_profile', 'UKMwpat_profile_deactivated_warning');
add_action('edit_user_profile', 'UKMwpat_profile_deactivated_warning');
// add_filter( 'user_contactmethods', 'UKMwpat_profile_fields' );
add_filter( "user_contactmethods", 'display_user_phone_number' );
add_filter( "user_user_phone_label", 'UKMwpat_profile_field_phone_description' );
add_filter('wp_is_application_passwords_available', '__return_false');
// Display user phone number in user profiles
function display_user_phone_number($user_contactmethods) {
$user_contactmethods['user_phone'] = 'Mobilnummer';
return $user_contactmethods;
}
function UKMwpat_profile_field_phone_description( $user ){
echo 'Mobilnummer <br />'.
'<small>'.
'Kontaktpunkt for UKM Norge';
}
add_filter('screen_options_show_screen', 'UKMdeactivate_screen_options');
function UKMdeactivate_screen_options() {
return false;
}
// Bytt ut avatarer
require_once('tweak.avatars.php');
add_filter( 'get_avatar' , 'ukm_avatar' , 1 , 5 );
// Legg til video som toppbilde-boks
add_action('add_meta_boxes', 'UKMwpat_add_video_box');
add_action('save_post', 'ukm_top_video_save');
require_once('tweak.user-fields.php'); # UTENFOR if(s_admin()) da den brukes av glemt passord!
if(is_admin()){
require_once('tweak.mediaform.php');
require_once('tweak.menu.php');
#require_once('tweak.adminmenu_build.php');
require_once('tweak.posts.php');
require_once('tweak.post-meta.php');
require_once('tweak.post-layout.php');
require_once('tweak.update-services.php');
require_once('tweak.multiauthor.php');
require_once('tweak.set-option.php');
require_once('tweak.post-recommendedfields.php');
require_once('tweak.gutenberg.php');
require_once('tweak.users.php');
add_action( 'admin_init', 'UKMwpat_logon_check' );
## ADD NETWORK UPDATE MENU
add_action('init', 'ActivateUpdateServices_init');
## HOOK MENU
// add_action('admin_menu', 'UKMwpat_tweak_menu_separators', 15000);
add_filter('parent_file', 'UKMwpat_tweak_menu_filter',-15000);
add_action('network_admin_menu', 'UKMwpat_tweak_network_menu', 300);
add_action( 'network_admin_menu', 'UKMwpat_set_option' );
add_action('admin_menu', 'UKMwpat_tweak_menu_remove', 300);
## CHANGE POSTS GUI
add_action( 'admin_menu', 'UKMwpat_remove_posts_meta_boxes',999 );
add_action( 'init', 'UKMwpat_remove_post_type_support',100 );
add_action('init', 'UKMwpat_change_allowed_tags');
add_action( 'add_meta_boxes', 'UKMwpat_add_tag_meta_box' );
add_action( 'save_post', 'ukmn_meta_box_save' );
add_action('delete_post', 'UKMwpat_related_delete', 10);
add_action('add_meta_boxes', 'UKMwpat_add_ma_box');
add_action( 'admin_enqueue_scripts', 'UKMwpat_add_ma_styles', 10000 );
// Stopp publisering og vis spørsmål om vi mangler info
add_action('admin_menu', 'UKMwpat_req_menu_hook');
add_action('save_post', 'UKMwpat_req_hook', 10002, 2);
add_action('admin_enqueue_scripts', 'UKMwpat_req_script', 10000 );
// Layout for festival-lignende sider
add_action( 'add_meta_boxes', 'UKMwpat_add_layout_meta_box' );
add_action( 'save_post', 'ukm_post_layout_save' );
add_filter('manage_posts_columns', 'UKMwpat_custom_post_columns');
wp_enqueue_style('tablefooter_hide', PLUGIN_PATH . 'UKMwp_admin-tweaks/css/tweak.tablefooter_hide.css');
## CHANGE UPLOAD / MEDIA GUI
add_filter('attachment_fields_to_edit', 'UKMwpat_mediaform', 20);
add_filter('media_meta', 'UKMwpat_editmedia');
add_filter('upload_mimes', 'UKMwpat_upload_mimes');
## USERS (EDIT FORM)
add_filter('user_contactmethods','UKMwpat_user_remove_controls',10,1);
add_action( 'admin_enqueue_scripts', 'UKMwpat_users_form' );
## USERS (TABELL)
add_filter( 'manage_users_columns', 'UKMwpat_modify_user_table', 100 );
add_filter('manage_users_custom_column', 'UKMwpat_modify_user_column', 100, 3);
## PASSWORDS
// add_filter('allow_password_reset', 'tr_restrict_password_reset');
add_action('login_head', 'tr_remove_reset_link_init');
add_filter('login_errors', 'tr_remove_reset_link');
wp_enqueue_style('tweak_wp_admin', PLUGIN_PATH . 'UKMwp_admin-tweaks/css/wp-admin.css', 100000);
}
require_once('tweak.admin_bar.php');
require_once('tweak.capabilities.php');
## CHANGE ROLE NAMES
add_action('init', 'UKMwpat_change_role_name');
add_action('current_screen', 'UKMwpat_change_role_name');
add_action('UKM_filter_roles', 'UKMwpat_change_role_name_raw');
add_action('wp_before_admin_bar_render','UKMwpat_modify_toolbar', 10000);
## Admin favicon
add_action( 'admin_head', 'UKMwpat_favicon' );
add_action('admin_enqueue_scripts', 'UKMwpat_load_scripts_and_styles');
function UKMwpat_favicon() {
echo '<link rel="shortcut icon" href="//ico.ukm.no/wp-admin_favicon.ico" />';
}
function UKMwpat_load_scripts_and_styles() {
wp_enqueue_script( 'ukmwpat_adminmenu_js', PLUGIN_PATH . 'UKMwp_admin-tweaks/js/tweak.adminmenu.js');
wp_enqueue_style('tweak_adminmenu', PLUGIN_PATH . 'UKMwp_admin-tweaks/css/tweak.adminmenu.css');
wp_enqueue_style('UKMArrSysStyle');
wp_enqueue_style('WPbootstrap3_css', 'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css');
wp_enqueue_script('WPbootstrap3_js', 'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js');
}
// Prevent WordPress from saving the biography data because biography
function prevent_biography_save($userId) {
if (isset($_POST['description'])) {
unset($_POST['description']);
}
}
add_action('personal_options_update', 'prevent_biography_save');
add_action('edit_user_profile_update', 'prevent_biography_save');
// Add page edit capability to editor role
function add_page_edit_capability_to_editor_role() {
$editor_role = get_role('editor');
$editor_role->add_cap('edit_pages');
$editor_role->add_cap('edit_others_pages');
$editor_role->add_cap('publish_pages');
}
add_action('init', 'add_page_edit_capability_to_editor_role');
// Prevent access to WordPress pages created by UKM by other users
function prevent_access_to_wordpress_pages_created_by_ukm() {
if(is_super_admin()) {
return;
}
// Sjekk hvis det er admin og at det er på redigering av en side
if (is_admin() && isset($_GET['post']) && isset($_GET['action']) && $_GET['action'] === 'edit') {
$post_id = $_GET['post'];
$current_post = get_post($post_id);
// Liste me sider som opprettes av systemet og kan ikke redigeres fra brukere
$excluded_page_slugs = array('bilder', 'kontaktpersoner', 'forside', 'nyheter', 'pameldte', 'program', 'lokalmonstringer', 'deltakerprogram', 'testside');
// Hvis brukeren prøver å redigere en system side
if ($current_post && in_array(get_post_field('post_name', $current_post), $excluded_page_slugs)) {
throw new Exception("Du har ikke tilgang til denne siden. '". get_post_field('post_name', $current_post) ."' brukes i systemet og kan ikke redigeres. Kontakt [email protected] for mer informasjon!");
exit;
}
}
}
add_action('admin_init', 'prevent_access_to_wordpress_pages_created_by_ukm');