-
Notifications
You must be signed in to change notification settings - Fork 1
/
pagecdn.php
156 lines (98 loc) · 4.17 KB
/
pagecdn.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
<?php
/*
Plugin Name: Easy Speedup by PageCDN
Text Domain: pagecdn
Description: Speedup WordPress websites with PageCDN's best-in-class Content, Delivery and Cache optimizations.
Author: PageCDN
Author URI: https://pagecdn.com
License: GPLv2 or later
Version: 5.13
*/
defined( 'ABSPATH' ) OR exit;
define( 'PAGECDN_FULL_NAME' , 'Easy Speedup by PageCDN' );
define( 'PAGECDN_FILE' , __FILE__ );
define( 'PAGECDN_DIR' , dirname( __FILE__ ) );
define( 'PAGECDN_BASE' , plugin_basename( __FILE__ ) );
define( 'PAGECDN_MIN_WP' , '4.3' );
//define( 'PAGECDN_CACHE' , WP_CONTENT_DIR . '/cache/pagecdn/cache.json' );
//define( 'PAGECDN_IMG_CACHE' , WP_CONTENT_DIR . '/cache/pagecdn/images.json' );
//define( 'PAGECDN_WEBP_CACHE' , WP_CONTENT_DIR . '/cache/pagecdn/webp.json' );
define( 'PAGECDN_VER' , '5.13' );
$PageCDN_origin_scheme = strtolower( parse_url( home_url( ) , PHP_URL_SCHEME ) );
$PageCDN_origin_host = parse_url( home_url( ) , PHP_URL_HOST );
$PageCDN_normalized_origin_host = strtolower( $PageCDN_origin_host );
if( strpos( $PageCDN_normalized_origin_host , 'www.' ) === 0 )
{
$PageCDN_normalized_origin_host = substr( $PageCDN_normalized_origin_host , 4 );
}
$PageCDN_settings_error = false;
$PageCDN_fonts = array();
$PageCDN_check_hosts = array( "https://www.{$PageCDN_normalized_origin_host}" ,
"https://{$PageCDN_normalized_origin_host}" ,
"http://www.{$PageCDN_normalized_origin_host}" ,
"http://{$PageCDN_normalized_origin_host}" ,
"//www.{$PageCDN_normalized_origin_host}" ,
"//{$PageCDN_normalized_origin_host}" );
require PAGECDN_DIR . '/init-functions.php';
require PAGECDN_DIR . '/functions.php';
require PAGECDN_DIR . '/font-functions.php';
require PAGECDN_DIR . '/admin-functions.php';
$PageCDN_known_URLs = array();
$PageCDN_known_img_URLs = array();
$PageCDN_known_webp_URLs = array();
$PageCDN_discovered_new_URLs = false;
$PageCDN_max_font_URLs = 3;
$PageCDN_webp_support = isset( $_SERVER['HTTP_ACCEPT'] ) && ( strpos( $_SERVER['HTTP_ACCEPT'] , 'image/webp' ) !== false );
$PageCDN_known_URLs = get_option( 'pagecdn-cache' , json_encode( array( ) ) );
$PageCDN_known_img_URLs = get_option( 'pagecdn-image-cache' , json_encode( array( ) ) );
$PageCDN_known_webp_URLs = get_option( 'pagecdn-webp-cache' , json_encode( array( ) ) );
$PageCDN_options = null;
if( !( isset( $PageCDN_theme_code ) && strlen( $PageCDN_theme_code ) ) )
{
$PageCDN_theme_code = 'easy-speedup';
}
# These lines are for removal in later versions
# Disabling Image Cache
update_option( 'pagecdn-image-cache' , json_encode( array( ) ) , false );
update_option( 'pagecdn-webp-cache' , json_encode( array( ) ) , false );
if( is_string( $PageCDN_known_URLs ) )
{
$PageCDN_known_URLs = json_decode( $PageCDN_known_URLs , true );
}
if( is_string( $PageCDN_known_img_URLs ) )
{
$PageCDN_known_img_URLs = json_decode( $PageCDN_known_img_URLs , true );
}
if( is_string( $PageCDN_known_webp_URLs ) )
{
$PageCDN_known_webp_URLs = json_decode( $PageCDN_known_webp_URLs , true );
}
/*
if( !file_exists( PAGECDN_CACHE ) )
{
PageCDN_create_fs_hierarchy( dirname( PAGECDN_CACHE ) );
$PageCDN_empty_file = json_encode( array() );
file_put_contents( PAGECDN_CACHE , $PageCDN_empty_file );
file_put_contents( PAGECDN_IMG_CACHE , $PageCDN_empty_file );
file_put_contents( PAGECDN_WEBP_CACHE , $PageCDN_empty_file );
}
$PageCDN_temp = file_get_contents( PAGECDN_CACHE );
if( $PageCDN_temp && strlen( $PageCDN_temp ) )
{
$PageCDN_known_URLs = json_decode( $PageCDN_temp , true );
}
unset( $PageCDN_temp );
$PageCDN_temp = file_get_contents( PAGECDN_IMG_CACHE );
if( $PageCDN_temp && strlen( $PageCDN_temp ) )
{
$PageCDN_known_img_URLs = json_decode( $PageCDN_temp , true );
}
unset( $PageCDN_temp );
$PageCDN_temp = file_get_contents( PAGECDN_WEBP_CACHE );
if( $PageCDN_temp && strlen( $PageCDN_temp ) )
{
$PageCDN_known_webp_URLs = json_decode( $PageCDN_temp , true );
}
unset( $PageCDN_temp );
*/
PageCDN_hooks( );