forked from Automattic/vip-go-mu-plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmisc.php
65 lines (59 loc) · 2.1 KB
/
misc.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
<?php
/*
Plugin Name: VIP Hosting Miscellaneous
Description: Handles CSS and JS concatenation, Nginx compatibility, SSL verification
Author: Automattic
Version: 1.1
License: GPL version 2 or later - http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*/
// Ensure we do not send the cache headers through to Varnish,
// so responses obey the cache settings we have configured.
function wpcom_vip_check_for_404_and_remove_cache_headers( $headers ) {
if ( is_404() ) {
unset( $headers['Expires'] );
unset( $headers['Cache-Control'] );
unset( $headers['Pragma'] );
}
return $headers;
}
add_filter( 'nocache_headers', 'wpcom_vip_check_for_404_and_remove_cache_headers' );
// Cleaner permalink options
add_filter( 'got_url_rewrite', '__return_true' );
// Checking for VIP_GO_ENV allows this code to work outside VIP Go environments,
// albeit without concatenation of JS and CSS.
if ( defined( 'VIP_GO_ENV' ) && false !== VIP_GO_ENV ) {
// Activate concatenation
if ( ! isset( $_GET['concat_js'] ) || 'yes' === $_GET['concat_js'] ) {
require __DIR__ .'/http-concat/jsconcat.php';
}
if ( ! isset( $_GET['concat_css'] ) || 'yes' === $_GET['concat_css'] ) {
require __DIR__ .'/http-concat/cssconcat.php';
}
}
/**
* This function uses the VIP_VERIFY_STRING and VIP_VERIFY_PATH
* constants to respond with a verification string at a particular
* path. So if you have a VIP_VERIFY_STRING of `Hello` and a
* VIP_VERIFY_PATH of `whatever.html`, then the URL
* yourdomain.com/whatever.html will return `Hello`.
*
* We suggest adding these constants in your `vip-config.php`
*
* @return void
*/
function action_wpcom_vip_verify_string() {
if ( ! defined( 'VIP_VERIFY_PATH' ) || ! defined( 'VIP_VERIFY_STRING' ) ) {
return;
}
$verification_path = '/' . VIP_VERIFY_PATH;
if ( $verification_path === $_SERVER['REQUEST_URI'] ) {
status_header( 200 );
echo VIP_VERIFY_STRING;
exit;
}
}
add_action( 'template_redirect', 'action_wpcom_vip_verify_string' );
/**
* Disable New Relic browser monitoring on AMP pages, as the JS isn't AMP-compatible
*/
add_action( 'pre_amp_render_post', 'wpcom_vip_disable_new_relic_js' );