-
Notifications
You must be signed in to change notification settings - Fork 8
/
pantheon-hud.php
45 lines (41 loc) · 1.15 KB
/
pantheon-hud.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
<?php
/**
* Plugin Name: Pantheon HUD
* Version: 0.4.5-dev
* Description: A heads-up display into your Pantheon environment.
* Author: Pantheon
* Author URI: https://pantheon.io
* Plugin URI: https://pantheon.io
* Text Domain: pantheon-hud
* Domain Path: /languages
*
* @package Pantheon HUD
*/
define( 'PANTHEON_HUD_ROOT_FILE', __FILE__ );
add_action(
'init',
function () {
$view_pantheon_hud = apply_filters( 'pantheon_hud_current_user_can_view', current_user_can( 'manage_options' ) );
if ( $view_pantheon_hud ) {
Pantheon\HUD\Toolbar::get_instance();
}
}
);
spl_autoload_register(
function ( $pantheon_class ) {
$class = ltrim( $pantheon_class, '\\' );
if ( 0 !== stripos( $class, 'Pantheon\HUD\\' ) ) {
return;
}
$parts = explode( '\\', $class );
array_shift( $parts ); // Don't need "Pantheon".
array_shift( $parts ); // Don't need "HUD".
$last = array_pop( $parts ); // File should be 'class-[...].php'.
$last = 'class-' . $last . '.php';
$parts[] = $last;
$file = __DIR__ . '/inc/' . str_replace( '_', '-', strtolower( implode( '/', $parts ) ) );
if ( file_exists( $file ) ) {
require $file;
}
}
);