-
Notifications
You must be signed in to change notification settings - Fork 0
/
boilerup-wp.php
210 lines (171 loc) · 8.85 KB
/
boilerup-wp.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
<?php
/*
Plugin Name: Purdue University Branding
Plugin URI: http://www.purdue.edu
description: Add Purdue University fonts, favicon and logos to WordPress
Version: 1.8.5
Author: Purdue Marketing and Communications
Author URI: https://marcom.purdue.edu
*/
if ( !defined('ABSPATH') ) {
header( 'HTTP/1.0 403 Forbidden' );
die;
}
if ( ! class_exists( 'PurdueBranding' ) ) :
/**
*
*/
class PurdueBranding {
private static $myURL;
public function __construct() {
if (is_link( WP_CONTENT_DIR . '/mu-plugins' )) {
self::$myURL = WP_CONTENT_URL . '/mu-plugins/boilerup-wp/';
} else {
self::$myURL = plugin_dir_url( __FILE__ );
}
self::includes();
self::hooks();
}
private static function includes() {
require_once dirname( __FILE__ ) . '/admin/boilerup-config-options.php';
new PurdueBranding_Settings_Page();
}
private static function hooks() {
$settings = get_option('bolierup_branding');
//Brand Fonts
if ( ! isset($settings['boilerup-brandfonts']) ) {
add_action( 'wp_enqueue_scripts', array( __CLASS__, 'adobeFonts' ) );
add_action( 'wp_enqueue_scripts', array( __CLASS__, 'unitedsansFont' ) );
add_action( 'wp_enqueue_scripts', array( __CLASS__, 'sourceSerifPro' ) );
add_action( 'admin_enqueue_scripts', array( __CLASS__, 'adobeFonts' ) );
add_action( 'admin_enqueue_scripts', array( __CLASS__, 'unitedsansFont' ) );
add_action( 'admin_enqueue_scripts', array( __CLASS__, 'sourceSerifPro' ) );
}
// Favicon
if ( ! isset($settings['boilerup-favicon']) ) {
add_action( 'wp_head', array( __CLASS__, 'add_header_icons' ) );
}
$disableTest = isset($_ENV['PANTHEON_ENVIRONMENT']) ? false : true;
if ( $disableTest ) {
add_filter( 'site_status_tests', array( __CLASS__, 'disable_managed_tests') );
}
// Login Form Branding
add_action( 'login_enqueue_scripts', array( __CLASS__, 'my_login_logo') );
add_filter( 'login_headerurl', array( __CLASS__, 'my_login_logo_url') );
add_filter( 'login_headertext', array( __CLASS__, 'my_login_logo_url_title') );
}
public static function adobeFonts() {
wp_enqueue_style(
'brandfonts', 'https://use.typekit.net/ghc8hdz.css'
);
}
public static function unitedsansFont() {
wp_enqueue_style(
'unitedsans', esc_url( self::$myURL . 'unitedsans.css' )
);
}
public static function sourceSerifPro() {
wp_enqueue_style(
'sourceserif', 'https://fonts.googleapis.com/css2?family=Source+Serif+Pro:wght@400;600;700&display=swap'
);
}
public static function add_header_icons() {
?>
<link rel="shortcut icon" href="<?php echo esc_url( self::$myURL . 'favicon/favicon.ico'); ?>" type="image/x-icon" />
<link rel="apple-touch-icon" sizes="57x57" href="<?php echo esc_url( self::$myURL . 'favicon/apple-icon-57x57.png');?>">
<link rel="apple-touch-icon" sizes="60x60" href="<?php echo esc_url( self::$myURL . 'favicon/apple-icon-60x60.png');?>">
<link rel="apple-touch-icon" sizes="72x72" href="<?php echo esc_url( self::$myURL . 'favicon/apple-icon-72x72.png');?>">
<link rel="apple-touch-icon" sizes="76x76" href="<?php echo esc_url( self::$myURL . 'favicon/apple-icon-76x76.png');?>">
<link rel="apple-touch-icon" sizes="114x114" href="<?php echo esc_url( self::$myURL . 'favicon/apple-icon-114x114.png');?>">
<link rel="apple-touch-icon" sizes="120x120" href="<?php echo esc_url( self::$myURL . 'favicon/apple-icon-120x120.png');?>">
<link rel="apple-touch-icon" sizes="144x144" href="<?php echo esc_url( self::$myURL . 'favicon/apple-icon-144x144.png');?>">
<link rel="apple-touch-icon" sizes="152x152" href="<?php echo esc_url( self::$myURL . 'favicon/apple-icon-152x152.png');?>">
<link rel="apple-touch-icon" sizes="180x180" href="<?php echo esc_url( self::$myURL . 'favicon/apple-icon-180x180.png');?>">
<link rel="icon" type="image/png" sizes="192x192" href="<?php echo esc_url( self::$myURL . 'favicon/android-icon-192x192.png');?>">
<link rel="icon" type="image/png" sizes="32x32" href="<?php echo esc_url( self::$myURL . 'favicon/favicon-32x32.png');?>">
<link rel="icon" type="image/png" sizes="96x96" href="<?php echo esc_url( self::$myURL . 'favicon/favicon-96x96.png');?>">
<link rel="icon" type="image/png" sizes="16x16" href="<?php echo esc_url( self::$myURL . 'favicon/favicon-16x16.png');?>">
<link rel="manifest" href="<?php echo esc_url( self::$myURL . 'favicon/manifest.json');?>">
<meta name="msapplication-TileColor" content="#ffffff">
<meta name="msapplication-TileImage" content="<?php echo esc_url( self::$myURL . 'favicon/ms-icon-144x144.png');?>">
<meta name="theme-color" content="#ffffff">
<?php
}
public static function my_login_logo_url_title() {
return esc_html__('Admin Log In: Purdue University', 'purdue');
}
public static function my_login_logo_url() {
return 'https://www.purdue.edu/';
}
public static function my_login_logo() { ?>
<style type="text/css">
#login h1 a, .login h1 a {
background-image: url(<?php echo esc_url(self::$myURL . 'img/purdue-logo.png'); ?>) !important;
height:57px !important;
width:320px !important;
background-size: 320px 57px !important;
background-repeat: no-repeat !important;
padding-bottom: 20px !important;
padding-left: 10px !important;
}
body.login {
background: #f0f0f0 !important;
}
.login #login_error, .login .message {
border-left: 4px solid #98700D !important;
}
body.login div#login p#nav a, body.login div#login p#backtoblog a {
color: #000000 !important;
}
body.login div#login p#nav a:hover, body.login div#login p#backtoblog a:hover {
color: #C28E0E !important;
}
.wp-core-ui .button-primary {
background-color: #98700D !important;
background: #98700D !important;
border-color: #98700D !important;
border-bottom-color: #98700D !important;
box-shadow: rgba(0, 0, 0, 0.3) 1px 1px 0 !important;
text-shadow: rgba(0, 0, 0, 0.3) 0 -1px 0 !important;
font-weight: bold !important;
}
.wp-core-ui .button-primary:hover {
background-color: #C28E0E !important;
background: #C28E0E !important;
border-color: #98700D !important;
box-shadow: rgba(0, 0, 0, 0.3) 1px 1px 0 !important;
text-shadow: rgba(0, 0, 0, 0.3) 0 -1px 0 !important;
font-weight: bold !important;
}
.login input:focus {
border-color: #C28E0E !important;
box-shadow: 0 0 2px rgba(194, 142, 14, 0.8) !important;
}
.login input[type=checkbox]:checked:before {
color: #000000 !important;
}
</style>
<?php }
/**
* Disable health checks for managed features
*
* These tests aren't useful in this environment, and distract from
* legitimate tests.
*/
public static function disable_managed_tests( $tests ) {
// The WordPress version is controlled by monthly auto-updates
unset( $tests['direct']['wordpress_version'] );
// The PHP version is set by the system vendor and cannot be updated
unset( $tests['direct']['php_version'] );
// The MySQL version is set by the ITIS DBA team and changes slowly
unset( $tests['direct']['sql_server'] );
// REST isn't available off campus for security reasons
unset( $tests['direct']['rest_availability'] );
// WordPress isn't allowed to update itself for security reasons
unset( $tests['async']['background_updates'] );
// Send overrides to WordPress
return $tests;
}
}
new PurdueBranding();
endif;